package com.fitapp;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
	
	static final String DBNAME = "FitAppDB";
	static final int DBVERSION = 1;
	public static final String TYPE_RUNNING = "running";
	public static final String TYPE_BENDING = "bending";
	public static final String TYPE_PRESSUP = "Press up";
	public static final String TYPE_SITUP = "Sit up";
	
	public DatabaseHelper(Context context) {
		super(context, DBNAME, null, DBVERSION);
	}

	@Override
    public void onCreate( SQLiteDatabase db )
    {
		db.execSQL( "CREATE TABLE Activities"
				+ "("
				+ "Id INTEGER PRIMARY KEY,"
				+ "Type TEXT,"
				+ "Date INT,"
				+ "Time INT,"
				+ "Count INT,"
				+ "Trackpoints TEXT"
				+ ")" );
		db.execSQL( "CREATE TABLE Goals"
				+ "("
				+ "Id INTEGER PRIMARY KEY,"
				+ "Type TEXT,"
				+ "Duration INT,"
				+ "Reached INT,"
				+ "Intended INT"
				+ ")" );
		String[] types = new String[4];
		types[0] = TYPE_BENDING;
		types[1] = TYPE_PRESSUP;
		types[2] = TYPE_RUNNING;
		types[3] = TYPE_SITUP;
		for (int i=1; i<=4; i++) {
			ContentValues values = new ContentValues();
			values.put( "Type", types[i-1] );
			values.put( "Duration", 30 );
			values.put( "Reached", 0 );
			values.put( "Intended", 100 );
			db.insert( "Goals", null, values );

		}	    
    }

	@Override
    public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion )
    {
	
    }
	
	
}

